package users

import (
	"context"
	"user_srv/userclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type MarkMessageReadLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewMarkMessageReadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MarkMessageReadLogic {
	return &MarkMessageReadLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *MarkMessageReadLogic) MarkMessageRead(req *types.MarkMessageReadRequest) (resp *types.Response, err error) {
	_, err = l.svcCtx.UserRpc.MarkMessageRead(l.ctx, &userclient.MarkMessageReadReq{
		MessageId: req.MessageId,
	})
	return &types.Response{
		Code:    200,
		Message: "您已阅读消息",
		Data:    true,
	}, nil
}
